from timeit import Timer

import sys
import math


def Problem():
    """The series, 1^(1) + 2^(2) + 3^(3) + ... + 10^(10) = 10405071317.

    Find the last ten digits of the series, 
    1^(1) + 2^(2) + 3^(3) + ... + 1000^(1000)."""
    
           
#===============================================================================
#    #Method 1 
#    mult = lambda x,  y: int(int(x) * int(y))
#    series = [reduce(mult, [x for y in xrange(x)], 1) for x in xrange(1, 1001)]
#    result = sum(series)
#    
#    ans = str(result)[-10:]
#===============================================================================
    
    
    #Method 2
    result = sum([int(x**x) for x in xrange(1, 1001)])
    ans = str(result)[-10:]
    
    print "Answer for Problem 48 = %s " % (ans,)


    
if __name__ == "__main__":
    t = Timer(setup='from __main__ import Problem', stmt='Problem()').timeit(1)
    print "Execution time = %0.3f seconds" %(t,)